package com.sinaapp.kltq.dinosaurweather;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;


public class showNotice extends ActionBarActivity {

    private TextView noticeTitle=null;
    private TextView noticeType=null;
    private TextView updateTime=null;
    private TextView noticeDetails=null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_notice);

        noticeTitle=(TextView)findViewById(R.id.noticeAddr);
        noticeType=(TextView)findViewById(R.id.noticeType);
        updateTime=(TextView)findViewById(R.id.updateTime);
        noticeDetails=(TextView)findViewById(R.id.noticeDetails);

        Intent intent=getIntent();

        String cityName=intent.getStringExtra("cityName");
        String alarmText=intent.getStringExtra("alarmText");
        String time=intent.getStringExtra("time");
        String alarmDetails=intent.getStringExtra("alarmDetails");

        noticeTitle.setText(cityName);
        noticeType.setText(alarmText);
        updateTime.setText(time);
        noticeDetails.setText(alarmDetails);

//        System.out.println("showNotice");
//        System.out.println(cityName);
//        System.out.println(alarmText);
//        System.out.println(time);
//        System.out.println(alarmDetails);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_show_notice, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

   /* @Override
    public boolean onKeyDown(int keyCode, KeyEvent event){
        if (keyCode == KeyEvent.KEYCODE_BACK )
        {
            Intent intent=new Intent(showNotice.this,BeginningActivity.class);
            System.out.println("onBackPressed");
            showNotice.this.startActivity(intent);
            showNotice.this.finish();
        }
            return false;
    }*/
    @Override
    public void onBackPressed() {
        Intent intent=new Intent(showNotice.this,BeginningActivity.class);
        System.out.println("onBackPressed");
        showNotice.this.startActivity(intent);
        finish();


    }
}
